]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Center window previews horizontally and vertically
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 14 Jan 2021 21:48:15 +0000 (22:48 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 8 Apr 2021 17:51:15 +0000 (17:51 +0000)
Window previews looks slightly offset to the left and top right now
because we don't use the same padding on all edges of the Workspace. We
do that because the oversize and overlap of the window previews is
different on all sides (for example the bottom overlap is very large
because there we show the window title).

To make sure window previews are always perfectly centered on the
Workspace, only use the largest one of the oversize values as spacing
and padding, and add the larger one of the overlap values for the
vertical padding in addition.

With this, we now center the window previews on the Workspace while
never overpainting the allocation of that Workspace to show overlays.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3634

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1670>

js/ui/workspace.js

index 1a5bd02271ace33036ab1f7e2cd44cb9fdacb066..2d6764dc41819b6053fb1931c7c84a0723cce864 100644 (file)
@@ -467,17 +467,22 @@ var WorkspaceLayout = GObject.registerClass({
         const [topOversize, bottomOversize] = window.chromeHeights();
         const [leftOversize, rightOversize] = window.chromeWidths();
 
+        const oversize =
+            Math.max(topOversize, bottomOversize, leftOversize, rightOversize);
+
         if (rowSpacing !== null)
-            rowSpacing += topOversize + bottomOversize;
+            rowSpacing += oversize;
         if (colSpacing !== null)
-            colSpacing += Math.max(leftOversize, rightOversize);
+            colSpacing += oversize;
 
         if (containerBox) {
             const [topOverlap, bottomOverlap] = window.overlapHeights();
-            containerBox.x1 += leftOversize;
-            containerBox.x2 -= rightOversize;
-            containerBox.y1 += topOversize + topOverlap;
-            containerBox.y2 -= bottomOversize + bottomOverlap;
+            const overlap = Math.max(topOverlap, bottomOverlap);
+
+            containerBox.x1 += oversize;
+            containerBox.x2 -= oversize;
+            containerBox.y1 += oversize + overlap;
+            containerBox.y2 -= oversize + overlap;
         }
 
         return [rowSpacing, colSpacing, containerBox];